package com.zg.api.web;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.zg.api.domain.req.ApiInfoAddReq;
import com.zg.api.domain.req.ApiInfoEditReq;
import com.zg.api.domain.req.ApiInfoPageReq;
import com.zg.api.domain.vo.ApiInfoVo;
import com.zg.api.service.ApiInfoService;
import com.zg.common.core.R;
import io.swagger.annotations.Api;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.validation.constraints.NotEmpty;
import java.util.List;

/**
 * <p>Description: </p>
 *
 * @author zhanfeng.liang
 * @since 2025/6/16 20:23
 */

@RestController
@RequiredArgsConstructor
@RequestMapping("/api/info")
@Slf4j
@Api(tags = "接口信息")
public class ApiInfoController {

    private final ApiInfoService apiInfoService;

    @PostMapping("/page")
    public R page(@RequestBody ApiInfoPageReq pageReq) {
        Page<ApiInfoVo> page = apiInfoService.page(pageReq, ApiInfoVo.class);
        return R.success(page);
    }


    @PostMapping("/add")
    public R add(@Validated @RequestBody ApiInfoAddReq addReq) {
        apiInfoService.add(addReq);
        return R.success();
    }

    @PostMapping("/edit")
    public R edit(@Validated @RequestBody ApiInfoEditReq editReq) {
        apiInfoService.edit(editReq);
        return R.success();
    }

    @PostMapping("/remove")
    public R remove(@RequestBody  List<Long> ids) {
        apiInfoService.remove(ids);
        return R.success();
    }


}
